package com.example.tetris.logics.components;

import java.io.Serializable;
import java.util.Objects;

enum CellType{
    NORMAL,
    BONUS
}

public class Cell implements Serializable,Cloneable {
    private  int x;
    private int y;
    private CellType cellType;

    public Cell(int x,int y){
        this.x = x;
        this.y = y;
        this.cellType = CellType.NORMAL;
    }
    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void setCellType(CellType cellType) {
        this.cellType = cellType;
    }



    public void setFilled(){
        cellType = CellType.NORMAL;
    }

    public void setBonus(){
        cellType = CellType.BONUS;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    @Override
    public Cell clone() {
        try {
            Cell clone = (Cell) super.clone();
            // TODO: copy mutable state here, so the clone can't change the internals of the original
            return clone;
        } catch (CloneNotSupportedException e) {
            throw new AssertionError();
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Cell cell = (Cell) o;
        return x == cell.x && y == cell.y && cellType == cell.cellType;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y, cellType);
    }

    @Override
    public String toString() {
        return "Cell{" +
                "x=" + x +
                ", y=" + y +
                ", cellType=" + cellType +
                '}';
    }
}
